package DataAccess.Storage;

import java.io.Serializable;
import DistSys.ShadingOption;
/**
 * Title:        iPAD
 * Description:
 * Copyright:    Copyright (c) 2002
 * Company:      ABB Inc.
 * @author Fangxing Li
 * @version 1.0
 */

public class ShadingForStorage implements Serializable{
  public static final long serialVersionUID=100203L;

  protected String  sDesc;
  protected int     iIndex;
  protected int     iIsResult;
  protected int     iContinuous;
  protected int     iAutoScale;
  protected double  dPercentBelow;
  protected double  dPercentAbove;
  protected double  dStart;
  protected double  dEnd;

  public ShadingForStorage() { }

  public void copyFromShadingOption ( ShadingOption so ) {
      this.sDesc = so.getDescription();
      this.iIndex = so.getIndex();
      if( so.getIsResult() )  { this.iIsResult =1; }  else { this.iIsResult=0;}
      if( so.getContinuous()) { this.iContinuous =1;} else { this.iContinuous=0;}
      if( so.getAutoScale())  { this.iAutoScale = 1;} else { this.iAutoScale =0;}
      this.dPercentBelow = so.getPercentBelow();
      this.dPercentAbove = so.getPercentAbove();
      this.dStart = so.getStartValue();
      this.dEnd = so.getEndValue();
      //System.out.println( "save: "+sDesc + "?= " + so.getDescription());
  }

  public ShadingOption createShadingOptionFromThis( ){
      ShadingOption so = new ShadingOption( );
      so.setDescription( this.sDesc);
      so.setIndex( this.iIndex);
      so.setIsResult( (this.iIsResult==1) );
      so.setContinuous( (this.iContinuous==1) );
      so.setAutoScale( (this.iAutoScale==1) );
      so.setPercentBelow( this.dPercentBelow);
      so.setPercentAbove( this.dPercentAbove);
      so.setStartValue( this.dStart);
      so.setEndValue( this.dEnd);
      //System.out.println( "load: "+ sDesc + "?= " + so.getDescription() );
      return so;
  }

  public String getDesc(){ return this.sDesc; }
}